package user

import (
	"feng-che.com/server/driver-quiz/internal/dep_db"
	"go.mongodb.org/mongo-driver/bson/primitive"
	"go.mongodb.org/mongo-driver/mongo"
	"luyouxin.com/person"
	"mongoDB"
)

// User 所有可以接触系统的非客户人员
type User struct {
	mongoDB.MongoDefaultModelNonID `bson:"basic"`
	ID                             primitive.ObjectID `json:"id" bson:"_id,omitempty"`
	person.Person
	InstitutionID      primitive.ObjectID `json:"institutionID" bson:"institution_id"`            // 机构ID
	IsInstitutionStaff bool               `json:"isInstitutionStaff" bson:"is_institution_staff"` // 是否是考场工作人员
	SchoolID           primitive.ObjectID `json:"schoolID" bson:"school_id"`                      // 驾校ID
}

func (u *User) GetCollectionName() string {
	return "user"
}

func (u *User) GetCollection() *mongo.Collection {
	name := u.GetCollectionName()
	return dep_db.ObjectCollection(&name)
}

func NewUser() (u *User, err error) {
	u = new(User)
	err = u.Init()
	if err != nil {
		return nil, err
	}
	return
}

// New 尽量不用本方法
func (u *User) New() (*User, error) {
	return NewUser()
}
